<?php
// T�nh to�n name cho file cache
$script_name = $_SERVER["SCRIPT_NAME"]; 
$break = Explode('/', $script_name);
$file = $break[count($break) - 1];

$cachefile = 'cached/cache-'.substr_replace($file ,"",-4).'.html';
//$a = fopen($cachefile,'r');
//echo fread($a, filesize($cachefile));
//fclose($a);
// th?i gian luu cache t�nh theo gi�y, 7200s = 2h
$cachetime = 0; 
 //$time = time(); echo $time.'+'.$cachetime.'----'.filemtime($cachefile);die;
// Xu?t file cache ra, v?i 2 di?u ki?n: c� cache v� chua vu?t qu� cachetime
if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {
    echo "<!-- Cached page khoi tao ".date('H:i', filemtime($cachefile))." -->\n";
    include($cachefile); 
    exit;
}
ob_start(); // B?t buffer cho output
?>

